home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / c / library / dos / diverses / cexpress / keyboard / getscan.asm < prev    next >
Encoding:
Assembly Source File  |  1989-05-03  |  1.1 KB  |  39 lines

  1. ;char  get_scan();
  2.  
  3.     EXTRN  _memory_model:byte
  4.  
  5. _TEXT    SEGMENT BYTE PUBLIC 'CODE'
  6.     ASSUME CS:_TEXT
  7.     PUBLIC _get_scan
  8. _get_scan proc near
  9.     mov  dx,0ffh        ;assume no keystroke
  10.     mov  ah,1        ;BIOS func to chk buffer
  11.     int  16h        ;chk for keystroke
  12.     jz   L4            ;jump if buffer empty
  13.     mov  dl,ah        ;assume ASCII code
  14.     or   al,al        ;test for extended code
  15.     jnz  L4            ;jump if ASCII code
  16.     cmp  ah,84        ;test for func+shift keys
  17.     jb   L3            ;jump ahead if below
  18.     cmp  ah,94        ;test if Func + Shift
  19.     jnb  L1            ;jump ahead if not
  20.     sub  ah,25        ;figure the scan code
  21.     jmp  short L3        ;jump ahead and adjust
  22. L1:    cmp  ah,104        ;test if Func + Ctrl
  23.     jnb  L2            ;jump ahead if not
  24.     sub  ah,35        ;figure the scan code
  25.     jmp  short L3        ;jump ahead and adjust
  26. L2:    cmp  ah,114        ;test if Func + Alt
  27.     jnb  L3            ;jump ahead if not
  28.     sub  ah,45        ;figure the scan code
  29. L3:    add  ah,128        ;add 128 to extended code
  30.     mov  dl,ah        ;move value to DL
  31. L4:    mov  al,dl        ;set for return
  32.     cmp  _memory_model,0    ;quit
  33.     jle  quit        ;
  34.     db   0CBh        ;RET far
  35. quit:    ret            ;RET near
  36. _get_scan ENDP
  37. _TEXT    ENDS
  38.     END
  39.